<template>
  <div>
    <div class="pvTop1">
      <router-link :to="{path:'/agentsitedetail'}">
        <div class="pvTop1_1">
          <van-icon name="arrow-left" />
        </div>
      </router-link>
      <div class="pvTop1_2"><img src="../../../assets/pvicon.png" alt="PV"></div>
      <div class="pvTop1_3">PV</div>
    </div>
    <div class="pvBox">
      <div class="pvBox1">
        <div class="pvBox1_1">{{$t('PanelSize')}}</div>
        <div class="pvBox1_2">{{resData.systemSize | numFilter(2,'kW')}}</div>
      </div>
      <div class="pvBox2">
        <div class="pvBox1_1">{{$t('PVPower')}}</div>
        <div class="pvBox1_2">{{resData.realtimepower | numFilter(1,'W')}}</div>
      </div>
    </div>
  </div>
</template>

<script>
import moment from 'moment'

export default {
  data(){
    return {
      resData:{},
      fifteenRefresh:null
    }
  },
  methods: {
    async getSiteAndPv(){
      this.comm.loadingShow();
      let res = await this.API.getPvData(localStorage.getItem("domain"),{
        'tokenId':localStorage.getItem("tokenId"),
        'siteId':localStorage.getItem('siteId'),
        'today':moment(new Date()).format('YYYY-MM-DD')
      })
      if(res.success){
        this.resData = res.result;
      }
    }
  },
  mounted() {
    this.getSiteAndPv();
    this.fifteenRefresh=setInterval(()=>{
      this.getSiteAndPv();
    },900000);
  },
  destroyed(){
    clearInterval(this.fifteenRefresh);
    this.fifteenRefresh=null;
  }
}
</script>

<style scoped lang="less">
.pvTop1{
  background: url("../../../assets/pvtop.png") no-repeat center  / 100% 100%;
  width: 100%;
  height: 150px;
  box-sizing: border-box;
}
.pvTop1_1{
  font-size: 30px;
  color: #FFFFFF;
  float: left;
  padding: 40px 16px 0 20px;
}
.pvTop1_2{
  float: left;
  padding-top: 38px;
  img{
    width: 50px;
  }
}
.pvTop1_3{
  font-size: 25px;
  font-weight: bolder;
  color: #FFFFFF;
  float: left;
  padding: 41px 0 0 10px;
}
.pvBox{
  position: absolute;
  top:95px;
  width: 100%;
  margin: 0 auto;
  padding:0 25px 10px 25px;
  box-sizing: border-box;
}
.pvBox1{
  height: 130px;
  width: 100%;
  background: url("../../../assets/dianzhan.png") no-repeat center / 100% 100%;
  border-radius: 5px;
  box-sizing: border-box;
}
.pvBox1_1{
  width: 100%;
  padding: 20px;
  color: #3B3D4E;
  font-size: 16px;
  text-align: left;
  box-sizing: border-box;
}
.pvBox1_2{
  width: 100%;
  padding: 10px 0 0 20px;
  font-size: 28px;
  color: #F9BC3C;
  text-align: left;
  box-sizing: border-box;
}
.pvBox2{
  height: 130px;
  width: 100%;
  background: url("../../../assets/shandian.png") no-repeat center / 100% 100%;
  border-radius: 5px;
}
</style>
